<template>
  <a-modal title-align="start" title="审核" :mask-closable="false" v-model:visible="showvisible" @cancel="showvisible = false" :width="400">
    <div>是否审核通过？</div>
    <div class="mt5">
      <a-radio-group v-model="isCheck">
        <a-radio :value="true">是</a-radio>
        <a-radio :value="false">否</a-radio>
      </a-radio-group>
    </div>

    <div class="mt10" v-if="!isCheck">
      <a-input v-model="reason" placeholder="请输入理由" />
    </div>
    <template #footer class="modal-footer">
      <a-button @click="showvisible = false">取消</a-button>
      <a-button type="primary" @click="submit">确定</a-button>
    </template>
  </a-modal>
</template>

<script lang="ts" setup>
  import { defineComponent, ref, computed, onMounted } from 'vue'
  import { checkTask } from '@/api/task'
  import { Message } from '@arco-design/web-vue'
  let props = defineProps(['modelValue', 'type', 'ids'])
  let emits = defineEmits(['save', 'update:modelValue'])
  let showvisible = computed({
    get() {
      return props.modelValue
    },
    set(val) {
      emits('update:modelValue', val)
    },
  })
  let isCheck = ref(true)
  let reason = ref('')
  const submit = async () => {
    if (!isCheck.value && !reason.value) return Message.error('请输入理由')
    let params: any = {
      accept: isCheck.value,
      idList: props.ids,
    }
    if (!isCheck.value) params.rejectReason = reason.value
    const res: any = await checkTask(params)
    if (res) {
      Message.success('审核成功')
      emits('save')
    }
    showvisible.value = false
  }
</script>

<style lang="less" scoped></style>
